<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ taglib prefix="c"
	uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>都市信息网</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="../css/style.css">
</head>
<body background="../images/back.gif">
	<center>
	
		<table border="0" width="920" cellspacing="0" cellpadding="0"
			bgcolor="white">
			<tr>
				<td colspan="2">
					<!-- 页眉 --> <iframe src="../admintop" frameBorder="0"
						width="920" scrolling="no" height="200"></iframe>

				</td>
			</tr>
			<tr>
				<td width="230" valign="top" align="center">
					<!-- 左边 --> <iframe src="../view/left.html" frameBorder="0"
						width="225" scrolling="no" height="400"></iframe>
				</td>
				<td width="690" height="400" align="center" valign="top"
					bgcolor="#FFFFFF">
					<form  onsubmit="return false;"  method="post">
					<table border="0" cellpadding="0" cellspacing="0" width="688"
						height="100%">
						<tr height="20">
							<td><img src="../images/default_t.jpg"></td>
						</tr>
						<tr>
							<td background="../images/default_m.jpg" valign="top"
								align="center"><input type="hidden" name="addType"
								value="add" />
								<table border="0" width="650" height="300" cellspacing="0">
									<tr height="30">
										<td style="text-indent: 10"><font color="#004790"><b>■发布信息</b></font></td>
									</tr>
									<tr>
										<td align="center">
											<table border="0" width="650" cellspacing="8">
												<tr>
													<td width="20%" style="text-indent: 10">信息类别：</td>
													<td><select name="infoSingle.infoType"
														id="info_Add_action_infoSingle_infoType">
															<c:if test="${empty requestScope.type }">
																<option value="0">暂时没有分类信息</option>
															</c:if>
															<c:if test="${!empty requestScope.type }">
																<c:forEach items="${requestScope.type}" var="temp">
																	<option value="${temp.type_sign}">${temp.type_name}</option>
																</c:forEach>
															</c:if>
													</select><span style="color: red;" id="msg_all"></span></td>
													<td align="right"><font color="#7F7F7F">[信息标题最多不得超过40个字符]&nbsp;&nbsp;</font></td>
												</tr>
												<tr>
													<td colspan="3"></td>
												</tr>
												<tr>
													<td style="text-indent: 10">信息标题：</td>
													<td colspan="2"><input type="text"
														name="infoSingle.infoTitle" size="80" maxlength="40"
														value="" id="info_Add_action_infoSingle_infoTitle"
														onkeydown="check_values()" onchange="check_values()" /> <span
														style="color: red;" id="msg_t"></span></td>
												</tr>
												<tr>
													<td colspan="3"></td>
												</tr>
												<tr>
													<td style="text-indent: 10">信息内容：</td>
													<td><font color="#7F7F7F"> 已用：<input
															type="text" name="ContentUse" id="contentuse" value="0"
															size="4" disabled style="text-align: center; border: 0;">
															个&nbsp;&nbsp; 剩余：<input type="text" name="ContentRem"
															id="contentrem" value="500" size="4" disabled
															style="text-align: center; border: 0;"> 个
													</font></td>
													<td align="right"><font color="#7F7F7F">[信息内容最多不得超过500个字符]&nbsp;&nbsp;</font><span
														style="color: red;" id="msg_co"></span></td>
												</tr>
												<tr>
													<td colspan="3"></td>
												</tr>
												<tr>
													<td colspan="3" align="center"><textarea
															name="infoSingle.infoContent" cols="75" rows="10"
															id="content" onkeyup="check(500)" onchange="check(500)"></textarea></td>
												</tr>
												<tr>
													<td style="text-indent: 10">联系电话：</td>
													<td colspan="2"><input type="text"
														name="infoSingle.infoPhone" size="45" value=""
														id="info_Add_action_infoSingle_infoPhone" /><span
														style="color: red;" id="msg_i"></span></td>
												</tr>
												<tr>
													<td colspan="3"></td>
												</tr>
												<tr>
													<td style="text-indent: 10">联 系 人：</td>
													<td colspan="2"><input type="text"
														name="infoSingle.infoLinkman" size="50" value=""
														id="info_Add_action_infoSingle_infoLinkman" /><span
														style="color: red;" id="msg_l"></span></td>
												</tr>
												<tr>
													<td colspan="3"></td>
												</tr>
												<tr>
													<td style="text-indent: 10">E - mail：</td>
													<td colspan="2"><input type="text"
														name="infoSingle.infoEmail" size="55" value=""
														id="info_Add_action_infoSingle_infoEmail" /><span
														style="color: red;" id="msg_e"></span></td>
												</tr>
												<tr>
													<td colspan="3"></td>
												</tr>
											</table>
										</td>
									</tr>
									<tr align="center" height="50">
										<td><input type="submit" id="info_Add_action_0"
											value="&#21457;&#24067;" onclick="return subDate();" /> <input
											type="reset" value="&#37325;&#22635;" /></td>
									</tr>
								</table></td>
						</tr>
						<tr height="26">
							<td><img src="../images/default_e.jpg"></td>
						</tr>
					</table>
					</form>
				</td>
			</tr>
		</table>
	</center>
	<script src="../js/jquery.min.js"></script>
	<script src="../js/check.js"></script>
	<script type="text/javascript">
		function check_values() {
			if ($("#info_Add_action_infoSingle_infoTitle").val().length > 40) {
				alert("标题过长!");
				return false;
			}
			return true;
		}

		function check(lg) {
			var content = $("#content").val();
			var contentrem = $("#contentrem").val();
			var contentuse = $("#contentuse").val();
			if (content.length <= lg) {
				document.getElementById("contentuse").value = ""
						+ content.length;
				document.getElementById("contentrem").value = 500 - content.length;
			} else {
				alert('信息内容过多！');
				document.getElementById("content").value = content.substring(0,
						lg);
			}
		}

		function subDate() {
			var sel = document
					.getElementById("info_Add_action_infoSingle_infoType").value;

			var title = $("#info_Add_action_infoSingle_infoTitle").val();
			title = trim(title);
			if (title.length < 5) {
				$("#msg_t").html('标题过短！');
				return false;
			} else {
				$("#msg_t").html('');
			}

			var content = $("#content").val();
			if (content.length < 8) {
				$("#msg_co").html('信息太少！');
				return false;
			} else {
				$("#msg_co").html('');
			}

			var phone = $("#info_Add_action_infoSingle_infoPhone").val();
			if (!checkTelephone(phone) && !checkMobilePhone(phone)) {
				$("#msg_i").html('电话格式不正确！');
				return false;
			} else {
				$("#msg_i").html('');
			}

			var linkman = $("#info_Add_action_infoSingle_infoLinkman").val();
			if (linkman.length > 10) {
				$("#msg_l").html('用户名过长！');
				return false;
			} else {
				$("#msg_l").html('');
			}
			if (linkman.length < 2) {
				$("#msg_l").html('用户名太短！');
				return false;
			} else {
				$("#msg_l").html('');
			}
			var email = $("#info_Add_action_infoSingle_infoEmail").val();
			if (!checkEmail(email)) {
				$("#msg_e").html('邮箱格式不正确！');
				return false;
			} else {
				$("#msg_e").html('');
			}

			if (email.length > 40) {
				$("#msg_e").html('邮箱过长！');
				return false;
			} else {
				$("#msg_e").html('');
			}
			$.post("add", {
				i_sel :trim(sel),
				i_title : trim(title),
				i_content : trim(content),
				i_phone : trim(phone),
				i_linkman : trim(linkman),
				i_mail : trim(email)
			}, function(data) {
				if(data.status == 200){
					window.location.href = './?id='+data.msg;
				}
				if (data.status == 400) {
					$("#msg_l").html(data.msg);
					return false;
				} else {
					$("#msg_l").html('');
				}
			});
		}
		
		$("#info_Add_action_infoSingle_infoTitle").focus();
	</script>
</body>
</html>